package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/17.
 */
@HttpInlet(Conn.INLET_API_COMMISSION_WITHDRAWSHOW)
public class GetApiShowTiXian extends BaseAsyGet<GetApiShowTiXian.Info> {
    public String userid;
    public GetApiShowTiXian(AsyCallBack<GetApiShowTiXian.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject){

        TOAST = jsonObject.optString("message");

        if (jsonObject.optInt("code") == 200){

            Info info = new Info();
            Data data = new Data();

            JSONObject o1 = jsonObject.optJSONObject("data");

            data.commission = o1.optString("commission");

            info.data = data;

            JSONArray jsonArray = jsonObject.optJSONArray("bank");

            if (jsonArray != null) {

                for (int i = 0; i < jsonArray.length(); i++) {

                    JSONObject o2 = jsonArray.optJSONObject(i);

                    Bank bank = new Bank();
                    bank.id = o2.optString("id");
                    bank.title = o2.optString("title");

                    info.bankList.add(bank);
                }
            }
            return info;
        }

        return null;
    }
    public static class Info{
        public String code,message;
        public Data data;
        public List<Bank> bankList = new ArrayList<>();
    }
    public static class Data{
        public String commission;
    }
    public static class Bank{
        public String id,title;
    }
}
//{
//        "code": 200,
//        "message": "成功",
//        "data": {
//        "commission": "0.00"
//        },
//        "bank": [
//        {
//        "id": "1",
//        "title": "建设银行"
//        },
//        {
//        "id": "2",
//        "title": "工商银行"
//        }
//        ]
//        }